package com.joysuch.wwyt.api.mh.entity;


import com.joysuch.wwyt.api.mh.bean.MhPlatformFieldBean;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;


@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_mh_platform")
@SQLDelete(sql = "update wwyt_mh_platform set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_mh_platform set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class MhPlatform implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键id")
    private Long id;

    @ApiModelProperty("平台名称")
    private String name;

    @ApiModelProperty("更新频率")
    private Integer frequency;

    @ApiModelProperty("传输方式id:1DB,2Rest,3Socket")
    private Integer transmissionModeId;

    @ApiModelProperty("账号")
    private String account;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("IP库名")
    private String ipLibraryName;

    @ApiModelProperty("表名称")
    private String tableName;

    @ApiModelProperty("URL地址")
    private String url;

    @ApiModelProperty("加密方式:数据字典id")
    private Long encryptionType;

    @Transient
    @ApiModelProperty("字段集合")
    List<MhPlatformFieldBean> fieldBeanList;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    private Long createBy;

    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private java.time.LocalDateTime createTime;

    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private java.time.LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    private String deleteFlag;
}
